package com.liujun.spring4.demo.aop.ioc.base.resource;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.util.FileCopyUtils;

import java.io.IOException;

/**
 * @author liujun
 * @version 1.0
 * @date 2018-08-11 08:36:00
 */
public class EncodeResourceExample {

  public static void main(String[] args)throws IOException {
    Resource res = new ClassPathResource("conf/file1.txt");
    EncodedResource encRes = new EncodedResource(res, "UTF-8");

    String contect = FileCopyUtils.copyToString(encRes.getReader());
    System.out.println(contect);
  }
}
